import Axios from "axios";


const MyAxios = {}
MyAxios.install = function (Vue) {
    const ax = Axios.create({
        baseURL: "http://localhost:8888/api/private/v1",
        headers: {
            'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjUwMCwicmlkIjowLCJpYXQiOjE2NDYyMjMxNjMsImV4cCI6MTY0NjMwOTU2M30.J73BJ0KPcMT56WR2GGDoxcnAvZYH8KPrsg_I6LWcxYI'
        },
    })
    ax.interceptors.request.use(function (config) {
        console.log(config)
        if (config.url !== '/login') {
            // 登陆之后才能获取token
            var token = JSON.parse(localStorage.getItem('userinfo')).token
            config.headers.Authorization = token
        }
        return config
    })
    Vue.prototype.$Req = ax
}


export default MyAxios